package cn.study.luckyinfrastructure.convertor;

import cn.study.luckydomain.rule.MinNum;
import cn.study.luckydomain.rule.RuleEntity;
import cn.study.luckyinfrastructure.gateway.iml.dataObject.RuleDB;

public class RuleConvertor {
    public static RuleDB toRuleDB(RuleEntity ruleEntity){
        RuleDB ruleDB = new RuleDB();
        ruleDB.setId(ruleEntity.getId());
        ruleDB.setRuleName(ruleEntity.getRuleName());
        ruleDB.setMaxJoinNumber(ruleEntity.getMaxJoinNumber().getNumber());
        ruleDB.setMaxWinningNumber(ruleEntity.getMaxWinningNumber().getNumber());
        ruleDB.setCreateTime(ruleEntity.getCreateTime());
        ruleDB.setCreator(ruleEntity.getCretor());
        ruleDB.setUpdateTime(ruleEntity.getUpdateTime());
        ruleDB.setUpdater(ruleEntity.getUpdater());
        return ruleDB;
    }
    public static RuleEntity toEntity(RuleDB ruleDB){
        RuleEntity ruleEntity = new RuleEntity();
        ruleEntity.setId(ruleDB.getId());
        ruleEntity.setRuleName(ruleDB.getRuleName());
        ruleEntity.setMaxJoinNumber(new MinNum(ruleDB.getMaxJoinNumber()));
        ruleEntity.setMaxWinningNumber(new MinNum(ruleDB.getMaxWinningNumber()));
        ruleEntity.setCreateTime(ruleDB.getCreateTime());
        ruleEntity.setCretor(ruleDB.getCreator());
        ruleEntity.setUpdateTime(ruleDB.getUpdateTime());
        ruleEntity.setUpdater(ruleDB.getUpdater());
        return ruleEntity;
    }
}
